var async = require("async");
var renderEngin = require("../common/renderEngin");
var Tools = require("../common/tools");
exports.bill_detail_trade = function (req, res) {
    use(["public/javascripts/bill_detail_trade/init.js", "public/javascripts/service/bill_detail_tradeService.js"], function (PageComponent, bill_detail_tradeService) {
        var storage = {};
        storage["slider"] = Tools.getPageSliderData("user_center");
        storage["billNo"] = req.query.id;
        storage["custUserId"] = req.query.uid;
        storage["type"] = req.query.type;
        storage["primary"] = req.query.primary == 'true' ? true : false;
        storage["interType"] = req.query.submodule;
        storage["current"] = 1;
        storage["pageSize"] = 10;

        var config = {
          'headers': req.headers,
          'urlParams':{
            'billNo': req.query.id
          },
          'seatParams':{
            'interType':req.query.submodule
          }
        };

        bill_detail_tradeService.searchOrders(config, function(result){
          if (result.errorCode == 0) {
              storage["orderList"] = result;
              storage["list"] = result.data;
              storage["total"] = result.pagination.totalResult;
          } else {
              storage["orderList"] = {};
              storage["list"] = [];
              storage["total"] = 0;
          }
          PageComponent = React.createFactory(PageComponent);
          renderEngin.call(res, 'bill_detail_trade', PageComponent, storage);
        });
    });
}
